# -*- coding: UTF-8 -*-

import logging


class JakaLogFormatter(logging.Formatter):
    """
    自定义 Formatter，将级别的日志 levelname 显示为单个字符
    """

    def format(self, record):
        if record.levelno == logging.DEBUG:
            record.levelname = "D"
        elif record.levelno == logging.INFO:
            record.levelname = "I"
        elif record.levelno == logging.ERROR:
            record.levelname = "E"
        elif record.levelno == logging.WARN:
            record.levelname = "W"
        elif record.levelno == logging.CRITICAL:
            record.levelname = "C"
        return super(JakaLogFormatter, self).format(record)
